#include "myClock.h"

/**
 * @brief myClock初始化：
 * 时间设为当前系统时间
 * 时间倍率置为1
 * 用户时间倍率置为1
 */
myClock::myClock()
{
    time = time.currentTime();
}

void myClock::setTime(int diff)
{
    time = time.currentTime();
    time = time.addMSecs(diff);
    this->diff = diff;
}

/**
 * @brief 用于调整时钟数据，模拟时钟运行
 */
void myClock::setTime()
{
    if(speed != 0)
    {
        time = time.currentTime();
        diff += 1000 / fps * (speed - 1);
        time = time.addMSecs(diff);
    }
    else
    {
        diff -= 1000 / fps;
    }
}
